﻿using System.Collections.Generic;
using System.Reactive.Subjects;
using System.Windows.Input;
using NUnit.Framework;
using Present.Commands.Decorators;
using Present.Commands.Fluent;
using Rhino.Mocks;

namespace Present.Commands.Tests.Decorators
{
    [TestFixture]
    public class CanExecuteChangedNotifierDecoratorTestCase : TestCase
    {
        private ICommand innerCommand;
        private CanExecuteChangedNotifierDecorator<ICommand, int> command;
        private Subject<int> observable;

        public override void Setup()
        {
            base.Setup();
            observable = new Subject<int>();
            innerCommand = MockRepository.GenerateStub<ICommand>();
            command = new CanExecuteChangedNotifierDecorator<ICommand, int>(observable, innerCommand);

        }

        [Test]
        public void NewItemInObervableTriggersCanExecuteChanged()
        {
            bool fired = false;
            command.CanExecuteChanged += (sender, e) => fired = true;
            observable.OnNext(1);
            Assert.IsTrue(fired);
        }
    }
}